﻿@{
    ViewBag.Title = ViewBag.typeName+"-2眼看书";
}
@section Head{
    <style>

    </style>

}


<div class="chapter">
    <div class="categoryMenu">
        <a href="@Url.Action("Category", "Book", new { typeid=1 })">玄幻魔法</a>
        <a href="@Url.Action("Category", "Book", new { typeid=2 })">武侠修真</a>
        <a href="@Url.Action("Category", "Book", new { typeid=3 })">都市言情</a>
        <a href="@Url.Action("Category", "Book", new { typeid=4 })">历史穿越</a>
        <a href="@Url.Action("Category", "Book", new { typeid=5 })">恐怖悬疑</a>
        <a href="@Url.Action("Category", "Book", new { typeid=6 })">游戏竞技</a>
        <a href="@Url.Action("Category", "Book", new { typeid=7 })">军事科幻</a>
        <a href="@Url.Action("Category", "Book", new { typeid=8 })">女生频道</a>
    </div>
</div>
<div class="chapter">
    <form method="get" class="search-form" action="@Url.Action("Search")">
        <input class="search-input" type="search" name="keyword" value="@ViewBag.Searchword" placeholder="输入小说名或作者名" />
        <button type="submit" class="search-btn">搜索</button>
    </form>
</div>
<div class="chapter">
    <dl class="am-cf sorttitle">
        <dt>@ViewBag.typeName</dt>
    </dl>
    <div class="bookBox">
        @*<a href="#" class="book">
            <div class="book-title">
                <h3>驭灵女盗</h3>
                <p>翦羽/连载中/玄幻</p>
            </div>
            <div class="book-desc">
                简介：地球末日，修真世界横空出世！灵气觉醒，被虚空大派纳徒，后被证明为修灵废体一朝休弃。少女苏瞳一夜从云端坠入黄泥，被迫流离。昔日故友背叛，新交师徒成仇。灵气不足我变法，求道无门我自修！狂女在烈火中淬炼，鲜肉强势回归故土。但波澜不止，地球与同胞被高价抛售！大派倾轧，阴谋重重，地球深处隐藏的终极秘密在面纱下浮动。星域中渺小的少女，为赎回家园而战。从此驭灵为奴，星盗崛......
            </div>
            <div class="book-update">
                更新：2016-12-12
            </div>
        </a>*@
    </div>

</div>
@section Scripts{
    <script>
        var canLoad = true;
        var Idx = parseInt("@ViewBag.idx");
        $(function () {
            loadBooks();
            $(window).scroll(function () {
                var scrollVal = $(window).scrollTop();
                var docHigh = $(document).height();
                var winHigh = $(window).height();
                //如果滚动条到底
                if (scrollVal == docHigh - winHigh && canLoad) {
                    loadBooks();
                }
            })

        })

        function loadBooks() {
            canLoad = false;
            $.ajax({
                type: "POST",
                url: '@Url.Action("BooksByCategory", "Book")',
                dataType: "json",
                data: 'typeid=@(ViewBag.typeid)&idx=' + Idx,
                success: function (data) {
                    var newBook = "";
                    if (data.length > 0)
                    {                     
                        data.forEach(function (item) {                          
                            newBook += "<a href=\"/book/ChapterList/"+item.id+"\" class=\"book\">";
                            newBook += "<div class=\"book-title\">";
                            newBook += "<h3>" + item.bookname + "</h3>";
                            newBook += "<p>" + item.author + "/" + item.typeName + "/"+item.isOver+"</p>";
                            newBook += "</div>";
                            newBook += "<div class=\"book-desc\">";
                            newBook += item.desc;
                            newBook += "</div>";
                            newBook += "<div class=\"book-update\">";
                            newBook += "更新："+item.updateDate;
                            newBook += "</div>";
                            newBook += "</a>";
                        })                      
                        canLoad = true;
                        Idx++;
                    }
                    else
                    {
                        newBook += "<a class=\"book\">";
                        newBook += "<div class=\"book-title\">";
                        newBook += "<h3>没有了！</h3>";
                        newBook += "</div>";                    
                        newBook += "</a>";
                    }
                    $(".bookBox").append(newBook);
                },
                beforeSend: function () {
                    $("#loading").show();
                },
                complete: function () {
                    $("#loading").hide();                    
                }
            });
        }
    </script>
}



